﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using MVCWorkflow.Models;

namespace MVCWorkflow.Workflows
{
public sealed class SetRelationship : CodeActivity
{
    public InArgument<int> ArticleID { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        DataContext db = new DataContext();

        var articleID = ArticleID.Get<int>(context);
        var article = db.Articles.Single(a => a.ArticleID == articleID);
        article.WorkflowID = context.WorkflowInstanceId;

        db.SaveChanges();
    }
}
}
